﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Trirand.Web;

//change cycle status to: in adjustment

namespace TestJQGrid
{
    public partial class Adjustments : System.Web.UI.Page
    {
        #region initialize & load default report
        TMAdjustments tm;

        protected void Page_Load(object sender, EventArgs e)
        {
            tm = TMAdjustments.Instance;
            loadReport2Grid();
        }

        private void loadReport2Grid()
        {
            DataTable dt = tm.getData();
            JQGrid1.DataSource = dt;
            JQGrid1.DataBind();
        }
        #endregion

        #region buttons at work
        protected void BCancel_Click(object sender, EventArgs e)
        {
            tm.reset();
            loadReport2Grid();
        }

        protected void BApply_Click(object sender, EventArgs e)
        {
            tm.UpdateDB();
            tm.reset();
            loadReport2Grid();
        }
        #endregion

        #region jqgrid operations
        protected void JQGrid1_RowEditing(object sender, Trirand.Web.UI.WebControls.JQGridRowEditEventArgs e)
        {
            tm.editRow(Convert.ToInt32(e.RowKey), e.RowData);
        }

        protected void JQGrid1_RowDeleting(object sender, Trirand.Web.UI.WebControls.JQGridRowDeleteEventArgs e)
        {
            tm.deleteRow(Convert.ToInt32(e.RowKey));
        }
        #endregion
    }
}